package com.itheima.mapper;

import com.itheima.domain.User;
import org.apache.ibatis.annotations.Many;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.mapping.FetchType;


import java.util.List;

public interface UsersMapper {

    @Select("select * from user")
    @Results({
            @Result(id=true,column = "id",property = "id"),
            @Result(column = "username",property = "name"),
            @Result(column = "address",property = "address"),
            @Result(
                    property = "orderList",
                    javaType = List.class,
                    column = "id",
                    many = @Many(select = "com.itheima.mapper.OrdersMapper.findByUid",fetchType = FetchType.EAGER)
            )
    })
    List<User> findUser();

}
